<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="$!webPath/css/template.css"  rel="stylesheet" type="text/css">
    <link href="$!webPath/css/jquery-ui-1.8.22.custom.css" type=text/css rel=stylesheet>
    <script src="$!webPath/js/jquery.min.js"></script>
    <script src="$!webPath/js/jquery-ui-1.8.21.js"></script>
    <script src="$!webPath/js/jquery.form.js"></script>
    <style type="text/css">
        html,body,ul,li{
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
        }
        label.error {
            color: #F00;
            margin-left: 3px;
        }

        input.error {
            border: 2px solid #F00;
        }
        .nav_list ul li{
            width: 150px;
        }
    </style>
    <script>

    </script>
</head>
<body>
    <div class="header_nav">
        <iframe name="content_frame" src="$!webPath/admin/nav" marginwidth=0 marginheight=0  frameborder=0 width=100% height=80/></iframe>
        <div class="cont_right"><a href="$!webPath/login">注销</a></div>
    </div>

    <div class="cont">
        <h3 class="seth">首页介绍管理</h3>
        <div class="nav_list">
            <ul>
                <li><a href="$!webPath/admin/introduction/introduction_list?size=10&page=0" class="this"><b>首页介绍列表</b></a></li>
                <li><a href="$!webPath/admin/homeIntroduction"><b>添加</b></a></li>
            </ul>
        </div>

        <form action="$!webPath/admin/" method="post" id="ListForm" >
            <div class="fshoptb">
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="fshop_table">
                    <tr>
                        <th width="5%">序号</th>
                        <th width="10%" align="center">名称</th>
                        <th width="20%" align="center">标题</th>
                        <th width="10%" align="center">创建时间</th>
                        <th width="10%" align="center">更新时间</th>
                        <th width="10%" align="center">创建人</th>
                        <th width="10%" align="center">更新人</th>
                        <th align="center">操作</th>
                    </tr>
                    <tbody id="introductions">
                    #foreach($obj in $!introductions)
                    <tr id="$!obj.id">
                        <td align="center">$!obj.sequence</td>
                        <td align="center">$!obj.name</td>
                        <td align="center">$!obj.shortTitle</td>
                        <td align="center">$!obj.createdAt</td>
                        <td align="center">$!obj.updateAt</td>
                        <td align="center">$!obj.createdBy</td>
                        <td align="center">$!obj.updateBy</td>
                        <td align="center" class="hui oprate_con">
                            <a href="$!webPath/admin/introduction/contents_list?homeId=$!obj.id" class="blue">查看</a>
                            <a id="btn_delete" href="#" class="blue" onclick="return activeDel('$!obj.id')">删除</a>
                            <a href="$!webPath/admin/homeIntroduction?homeIntroductionId=$!obj.id" class="blue">编辑</a>

                        </td>
                    </tr>
                    #end
                    </tbody>
                </table>
                <span id="spanFirst">第一页</span> <span id="spanPre">上一页</span> <span id="spanNext">下一页</span>
            </div>
            <div class="operate_bar">
                <div class="fenye">
                    $!gotoPageFormHTML
                </div>
            </div>
        </form>
    </div>
    <script>
        getUrlParam = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return decodeURI(r[2]); return null;
        }

        //替换指定传入参数的值,paramName为参数,replaceWith为新值
        function replaceParamVal(paramName,replaceWith) {
            var oUrl = this.location.href.toString();
            var re=eval('/('+ paramName+'=)([^&]*)/gi');
            var nUrl = oUrl.replace(re,paramName+'='+replaceWith);
            this.location = nUrl;
        }
        var pageSize = getUrlParam('size');
        var page = getUrlParam('page');
        $('#spanFirst').click(function () {
            page=0;
            $.ajax({
                url:'$!webPath/admin/introduction/introduction_list?size=10&page='+page,
                success:function(data){
                    console.log(data);
                    window.location.href='$!webPath/admin/introduction/introduction_list?size=10&page='+page;
                    replaceParamVal('page',page);
                }
            })
        })
        $('#spanNext').click(function(){
            page++;
            $.ajax({
                url:'$!webPath/admin/introduction/introduction_list?size=10&page='+page,
                success:function(data){
                    console.log(data);
                    window.location.href='$!webPath/admin/introduction/introduction_list?size=10&page='+page;
                    replaceParamVal('page',page);
                }
            })
        })

        $('#spanPre').click(function(){
            page--;
            if(page<=0){
                page=0;
            }
            $.ajax({
                url:'$!webPath/admin/introduction/introduction_list?size=10&page='+page,
                success:function(data){
                    console.log(data);
                    window.location.href='$!webPath/admin/introduction/introduction_list?size=10&page='+page;
                    replaceParamVal('page',page);
                }
            })
        })
        function activeDel(id){
            var that=this;
            if(confirm("你确定要删除吗？")){
                $.ajax({
                    url:'$!webPath/admin/introduction/introduction_delete?introductionId='+id,
                    type:'delete',
                    success: function () {
                        $('#'+id).remove();
                        window.location.reload();
                    },
                    error:function(){
                        alert('删除失败');
                    }
                })
            }
        }
    </script>
</body>
</html>

